/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rest.jbpm.wrappers.lists;

import java.util.*;
import javax.xml.bind.annotation.*;
import org.jbpm.pvm.internal.history.model.HistoryVariableImpl;
import rest.jbpm.wrappers.Variable;

/**
 *
 * @author jump
 */

@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(name = "history-variables", propOrder = {"variables"})
public class HistoryVariableList {

    private List<Variable> variables;

	protected HistoryVariableList() {

	}
    
    public HistoryVariableList(Collection<HistoryVariableImpl> vars) {
        variables = new ArrayList<Variable>();

		for(HistoryVariableImpl var : vars)
            variables.add(new Variable(var.getVariableName(), var.getValue()));
    }
    
	public HistoryVariableList(Map<String,?> vars) {

		variables = new ArrayList<Variable>();

		for(String name : vars.keySet())
			variables.add(new Variable(name,vars.get(name) == null ?
                "" : vars.get(name).toString()));
	}

	@XmlElement(name="variable" , required=true)
	public List<Variable> getVariables() {
		return variables;
	}

}
